package cn.south.campus.business.controller;

import cn.south.campus.business.model.req.WalletLogReq;
import cn.south.campus.business.model.vo.WalletLogVo;
import cn.south.campus.business.model.req.WalletReq;
import cn.south.campus.business.model.vo.WalletVo;
import cn.south.campus.business.model.vo.WithdrawalAuditVo;
import cn.south.campus.business.service.WalletLogService;
import cn.south.campus.business.service.WalletService;
import cn.south.campus.common.model.bo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *
 * </p>
 *
 * @author chow
 * @since 2024/11/14 13:27
 */
@AllArgsConstructor
@RestController
@RequestMapping("/campus/wallet")
public class WalletController {


    private final WalletService walletService;

    private final WalletLogService walletLogService;

    @PutMapping("recharge")
    public Result<String> recharge(@RequestBody WalletReq walletReq) {
        walletService.recharge(walletReq);
        return Result.success("充值成功");
    }

    @PutMapping("withdraw")
    public Result<String> withdraw(@RequestBody WalletReq walletReq) {
        walletService.withdraw(walletReq);
        return Result.success("提现成功");
    }

    @GetMapping("queryBalance")
    public Result<WalletVo> queryBalance() {
        return Result.success(walletService.queryBalance());
    }

    @GetMapping("queryRecord")
    public Result<IPage<WalletLogVo>> queryRecord(WalletLogReq req) {
        return Result.success(walletLogService.queryRecord(req));
    }

    @PutMapping("withdraw/callback")
    public Result<Void> withdrawCallback(@RequestBody WithdrawalAuditVo withdrawalAuditVo) {
        walletService.withdrawCallback(withdrawalAuditVo);
        return Result.success();
    }
}
